package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Home.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import gs.*;
	import gs.easing.*;
	import gs.events.TweenEvent;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.plaf.*;
	import org.aswing.skinbuilder.*;
	import org.aswing.table.*;
	import org.aswing.tree.*;
	public class FrameFriend extends JFrame
	{
		
		//members define
		private var panelHead:JPanel;
		private var labelName:JLabel;
		private var labelLevel:JLabel;
		private var panel30:JPanel;
		private var btn_friend_tab_friend:JToggleButton;
		private var btn_friend_tab_favorite:JToggleButton;
		private var btn_friend_tab_boring:JToggleButton;
		private var btn_friend_tab_tmp:JToggleButton;
		private var labelInfo:JLabel;
		private var btn_friend_refresh:JButton;
		private var panelFriends:JPanel;
		private var panel36:JPanel;
		private var btnPrev:JButton;
		private var labelPage:JLabel;
		private var btnNext:JButton;
		private var btn_add_friend:JButton;
		private var txt_add_friend_input:JTextField;
		
		//--------------
		private var btn_close:JButton;
	
		private var treeUserObjects:Array = new Array();
		public function FrameFriend()
		{
			//super();
			//setDragable(false);
			//setClosable(false);
			//setResizable(false);
			//setTitleBar(null);
			//setBorder(new EmptyBorder());
			//this.setBackgroundDecorator(new SolidBackground(new ASColor(0,0)));
			
			//component creation
			super();
			setResizable(false);
			setBackgroundDecorator(null);
			setBorder(new EmptyBorder());
			
			btn_close = new JButton();
			btn_close.setLocation(new IntPoint(198, -5));
			btn_close.setSize(new IntDimension(27, 27));
			btn_close.setPreferredSize(new IntDimension(27, 27));
			getTitleBar().setCloseButton(btn_close);
			getTitleBar().setMinimizeHeight(32);
			
			//component creation
			setSize(new IntDimension(188, 434));
			setPreferredSize(new IntDimension(188, 434));
			var layout0:EmptyLayout = new EmptyLayout();
			getContentPane().setLayout(layout0);
			
			panelHead = new JPanel();
			panelHead.setLocation(new IntPoint(4, -27));
			panelHead.setSize(new IntDimension(63, 63));
			panelHead.setPreferredSize(new IntDimension(63, 63));
			
			labelName = new JLabel();
			labelName.setLocation(new IntPoint(69, -9));
			labelName.setSize(new IntDimension(90, 18));
			labelName.setPreferredSize(new IntDimension(90, 18));
			labelName.setText("label");
			
			labelLevel = new JLabel();
			labelLevel.setLocation(new IntPoint(69, 10));
			labelLevel.setSize(new IntDimension(90, 18));
			labelLevel.setPreferredSize(new IntDimension(90, 18));
			labelLevel.setText("label");
			
			panel30 = new JPanel();
			panel30.setLocation(new IntPoint(7, 36));
			panel30.setSize(new IntDimension(174, 22));
			panel30.setPreferredSize(new IntDimension(174, 22));
			var layout1:FlowLayout = new FlowLayout();
			layout1.setAlignment(AsWingConstants.CENTER);
			layout1.setHgap(2);
			layout1.setVgap(0);
			panel30.setLayout(layout1);
			
			btn_friend_tab_friend = new JToggleButton();
			btn_friend_tab_friend.setLocation(new IntPoint(13, 0));
			btn_friend_tab_friend.setSize(new IntDimension(41, 22));
			btn_friend_tab_friend.setPreferredSize(new IntDimension(41, 22));
			btn_friend_tab_friend.setToolTipText("普通好友");
			btn_friend_tab_friend.setText("label");
			
			btn_friend_tab_favorite = new JToggleButton();
			btn_friend_tab_favorite.setLocation(new IntPoint(2, 22));
			btn_friend_tab_favorite.setSize(new IntDimension(41, 22));
			btn_friend_tab_favorite.setPreferredSize(new IntDimension(41, 22));
			btn_friend_tab_favorite.setToolTipText("猜你喜欢");
			btn_friend_tab_favorite.setText("label");
			
			btn_friend_tab_boring = new JToggleButton();
			btn_friend_tab_boring.setLocation(new IntPoint(2, 44));
			btn_friend_tab_boring.setSize(new IntDimension(41, 22));
			btn_friend_tab_boring.setPreferredSize(new IntDimension(41, 22));
			btn_friend_tab_boring.setToolTipText("猜你讨厌");
			btn_friend_tab_boring.setText("label");
			
			btn_friend_tab_tmp = new JToggleButton();
			btn_friend_tab_tmp.setLocation(new IntPoint(13, 66));
			btn_friend_tab_tmp.setSize(new IntDimension(41, 22));
			btn_friend_tab_tmp.setPreferredSize(new IntDimension(41, 22));
			btn_friend_tab_tmp.setToolTipText("临时好友");
			btn_friend_tab_tmp.setText("label");
			
			labelInfo = new JLabel();
			labelInfo.setLocation(new IntPoint(6, 59));
			labelInfo.setSize(new IntDimension(159, 16));
			labelInfo.setPreferredSize(new IntDimension(159, 16));
			labelInfo.setText("label");
			
			btn_friend_refresh = new JButton();
			btn_friend_refresh.setLocation(new IntPoint(165, 59));
			btn_friend_refresh.setSize(new IntDimension(16, 16));
			btn_friend_refresh.setPreferredSize(new IntDimension(16, 16));
			btn_friend_refresh.setToolTipText("刷新列表");
			btn_friend_refresh.setText("label");
			
			panelFriends = new JPanel();
			panelFriends.setLocation(new IntPoint(7, 78));
			panelFriends.setSize(new IntDimension(174, 269));
			panelFriends.setPreferredSize(new IntDimension(174, 269));
			var layout2:GridLayout = new GridLayout();
			layout2.setRows(6);
			layout2.setColumns(1);
			layout2.setHgap(0);
			layout2.setVgap(1);
			panelFriends.setLayout(layout2);
			
			panel36 = new JPanel();
			panel36.setLocation(new IntPoint(42, 349));
			panel36.setSize(new IntDimension(104, 24));
			panel36.setPreferredSize(new IntDimension(104, 24));
			var layout3:FlowWrapLayout = new FlowWrapLayout();
			layout3.setPreferWidth(200);
			layout3.setAlignment(AsWingConstants.CENTER);
			layout3.setHgap(5);
			layout3.setVgap(0);
			layout3.setMargin(false);
			panel36.setLayout(layout3);
			
			btnPrev = new JButton();
			btnPrev.setLocation(new IntPoint(61, 0));
			btnPrev.setSize(new IntDimension(29, 21));
			btnPrev.setPreferredSize(new IntDimension(29, 24));
			btnPrev.setText("label");
			
			labelPage = new JLabel();
			labelPage.setLocation(new IntPoint(41, 8));
			labelPage.setSize(new IntDimension(26, 17));
			labelPage.setPreferredSize(new IntDimension(36, 16));
			labelPage.setText("10/10");
			
			btnNext = new JButton();
			btnNext.setLocation(new IntPoint(132, 0));
			btnNext.setSize(new IntDimension(29, 24));
			btnNext.setPreferredSize(new IntDimension(29, 24));
			btnNext.setText("label");
			
			btn_add_friend = new JButton();
			btn_add_friend.setLocation(new IntPoint(165, 375));
			btn_add_friend.setSize(new IntDimension(18, 18));
			btn_add_friend.setPreferredSize(new IntDimension(18, 18));
			btn_add_friend.setText("label");
			
			txt_add_friend_input = new JTextField();
			txt_add_friend_input.setLocation(new IntPoint(6, 374));
			txt_add_friend_input.setSize(new IntDimension(159, 20));
			txt_add_friend_input.setPreferredSize(new IntDimension(159, 20));
			
			//component layoution
			getContentPane().append(panelHead);
			getContentPane().append(labelName);
			getContentPane().append(labelLevel);
			getContentPane().append(panel30);
			getContentPane().append(labelInfo);
			getContentPane().append(btn_friend_refresh);
			getContentPane().append(panelFriends);
			getContentPane().append(panel36);
			getContentPane().append(btn_add_friend);
			getContentPane().append(txt_add_friend_input);
			
			panel30.append(btn_friend_tab_friend);
			panel30.append(btn_friend_tab_favorite);
			panel30.append(btn_friend_tab_boring);
			panel30.append(btn_friend_tab_tmp);
			
			panel36.append(btnPrev);
			panel36.append(labelPage);
			panel36.append(btnNext);
			
			
			//------------------------------
			

			//this.getTitleBar().setMinimizeHeight(0);
			setImages();
			panelFriends.setClipMasked(false);
			getContentPane().bringToTop(panelFriends);
			setClipMasked(false);
			getContentPane().setClipMasked(false);
		}
		private var _mallItems:Array = new Array();
		
		public function setImages():void
		{
			var img_char_background:DisplayObject = Client.getUIElement("img_friend_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY(Engine.W - img_char_background.width-6,(Engine.H - img_char_background.height)/2+20);
			
			btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			btn_add_friend.wrapSimpleButton(Client.getUIElement("btn_friend_add") as SimpleButton);
			btn_add_friend.setText("");
			btn_close.setText("");
			btn_friend_refresh.wrapSimpleButton(Client.getUIElement("btn_friend_refresh") as SimpleButton);
			btn_friend_refresh.setText("");
			
			btn_friend_tab_friend.setSelected(true);
			
			btn_friend_tab_friend.wrapSimpleButton(Client.getUIElement("btn_friend_tab_friend") as SimpleButton);
			btn_friend_tab_friend.setText("");
			
			btn_friend_tab_favorite.wrapSimpleButton(Client.getUIElement("btn_friend_tab_favorite") as SimpleButton);
			btn_friend_tab_favorite.setText("");
			
			btn_friend_tab_boring.wrapSimpleButton(Client.getUIElement("btn_friend_tab_boring") as SimpleButton);
			btn_friend_tab_boring.setText("");
			btn_friend_tab_tmp.wrapSimpleButton(Client.getUIElement("btn_friend_tab_tmp") as SimpleButton);
			btn_friend_tab_tmp.setText("");
			
			var group:ButtonGroup = new ButtonGroup();
			group.appendAll(btn_friend_tab_friend,btn_friend_tab_favorite,btn_friend_tab_boring,btn_friend_tab_tmp);
			
			panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
			btnPrev.wrapSimpleButton(Client.getUIElement("btn_prev") as SimpleButton);
			btnNext.wrapSimpleButton(Client.getUIElement("btn_next") as SimpleButton);
			btnPrev.setText("");
			btnNext.setText("");
			
			btn_friend_tab_friend.addActionListener(onTabFriend);
			btn_friend_tab_favorite.addActionListener(onTabFavorite);
			btn_friend_tab_boring.addActionListener(onTabBoring);
			btn_friend_tab_tmp.addActionListener(onTabTmp);
			
			btnPrev.addActionListener(onBtnPrev);
			btnNext.addActionListener(onBtnNext);
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 10);
			labelPage.setForeground(ASColor.WHITE);
			labelPage.setFont(font);
			labelPage.setTextFilters(new Array(filter));
			
			labelName.setForeground(ASColor.WHITE);
			labelName.setFont(new ASFont("宋体", 13, false, false, false, false));
			labelName.setTextFilters(new Array(filter));
			
			labelLevel.setForeground(ASColor.WHITE);
			labelLevel.setFont(new ASFont("宋体", 13, false, false, false, false));
			labelLevel.setTextFilters(new Array(filter));
			
			labelInfo.setForeground(ASColor.WHITE);
			labelInfo.setFont(new ASFont("宋体", 12, false, false, false, false));
			labelInfo.setTextFilters(new Array(filter));
			
			

			txt_add_friend_input.setFont(font);
			txt_add_friend_input.setForeground(ASColor.GRAY);
			addEventListener(FrameEvent.FRAME_CLOSING,onFrameClose);
			addEventListener(MovedEvent.MOVED,onFrameMoved);

			

			btn_add_friend.addActionListener(onBtnAddFriend);
			
			btn_close.addActionListener(function () :void
			{
				FrameFriend.hide();
			});
			
			for(var i:int = 0; i < _itemsPerPage; i++)
			{
				var item:PaneFriendItem = new PaneFriendItem;
				panelFriends.append(item);
				_mallItems.push(item);
			}
			updatePage(0);
			labelInfo.setText("普通好友");
			//invalidate();
			//this.pack();
			//this.paintImmediately();
			txt_add_friend_input.setBackgroundDecorator(null);
			txt_add_friend_input.setText("这里输入要添加好友的名字");
			txt_add_friend_input.addEventListener(AWEvent.FOCUS_GAINED,onAddFriendFocusGained);
			txt_add_friend_input.addEventListener(AWEvent.FOCUS_LOST,onAddFriendFocusLost);
			
			addEventListener(FrameEvent.FRAME_CLOSING,onFrameClosing);
			addEventListener(AWEvent.HIDDEN,onFrameClosing);
		}
		private function onAddFriendFocusGained(event:Event):void
		{
			txt_add_friend_input.setForeground(ASColor.WHITE);
			if(txt_add_friend_input.getText() == "这里输入要添加好友的名字")
				txt_add_friend_input.setText("");
		}
		private function onAddFriendFocusLost(event:Event):void
		{
			txt_add_friend_input.setForeground(ASColor.GRAY);
			if(txt_add_friend_input.getText().length == 0)
				txt_add_friend_input.setText("这里输入要添加好友的名字");
		}
		private function onTabFriend(event:Event):void
		{
			_currentPageIndex = 0;
			updatePage(0);
			labelInfo.setText("普通好友");
		}
		private function onTabFavorite(event:Event):void
		{
			_currentPageIndex = 0;
			updatePage(1);
			labelInfo.setText("猜你喜欢");
		}
		private function onTabBoring(event:Event):void
		{
			_currentPageIndex = 0;
			updatePage(2);
			labelInfo.setText("猜你讨厌");
		}
		private function onTabTmp(event:Event):void
		{
			_currentPageIndex = 0;
			updatePage(3);
			labelInfo.setText("临时好友");
		}
		
		private var _currentType:int = 0;
		//private var _currentPage:int = -1;
		private var _currentPageIndex:int = 0;
		private var _currentPageIndexAll:int = 0;
		private var _itemsPerPage:int = 6;
		public function updatePage(nType:int):void
		{
			labelName.setText(CharInfo.charName);
			labelLevel.setText('Lv.'+CharInfo.m_nLevel);
			for each(var obj:Object in _mallItems)
			{
				obj.item = null;
			}

			_currentType = nType;
			var array:Array = null;
			if(nType == 0) array = CharInfo.m_arFriends;
			if(nType == 1) array = CharInfo.m_arFriendsFavorite;
			if(nType == 2) array = CharInfo.m_arFriendsBoring;
			if(nType == 3) array = CharInfo.m_arFriendsTmp;
			
			if(_currentPageIndex >= Math.floor((array.length+_itemsPerPage-1)/_itemsPerPage))
				_currentPageIndex = 0;
			
			var nIndex:int = 0;
			var nCount:int = 0;
			for each(var item:Object in array)
			{
				nCount++;
				if(nCount <= _currentPageIndex*_itemsPerPage)
					continue;
				_mallItems[nIndex++].item = item;
				if(nIndex >= _itemsPerPage)
					break;
			}
			
			var nCount1:int = array.length;
			_currentPageIndexAll = Math.floor((nCount1+_itemsPerPage-1)/_itemsPerPage);
			labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
			
			btnPrev.setEnabled(_currentPageIndex > 0 &&  _currentPageIndexAll > 1);
			btnNext.setEnabled(_currentPageIndex < _currentPageIndexAll-1 &&  _currentPageIndexAll > 1);
			
			FrameClickFriend.hide();
		}
		
		public function updateData():void
		{
			updatePage(_currentType);
		}
		
		private function onBtnPrev(event:Event):void
		{
			_currentPageIndex--;
			if(_currentPageIndex < 0)
				_currentPageIndex = 0;
			updatePage(_currentType);
			//labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
		}
		private function onBtnNext(event:Event):void
		{
			_currentPageIndex++;
			if(_currentPageIndex > _currentPageIndexAll-1)
				_currentPageIndex = _currentPageIndexAll-1;

			updatePage(_currentType);
			//labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
		}

		private function onBtnAddFriend(e:Event):void
		{
			//FrameInfo.showInputDialog(""," 请输入要添加好友的ID或名字: ",handleOptionAddFriend,"",null,true,null);
			var inputText:String = txt_add_friend_input.getText();
			if(inputText.length <= 0)
			{
				FrameInfo.showMessageDialog("","请输入要添加好友的ID或名字!",null,null,true,null);
				return;
			}
			var id:int = int(inputText);
			Client.getInstance().sendPacketLogic(601,[id,inputText]);
		}
		private function onBtnTrends(e:Event):void
		{
			trace("FrameTrends.show()")
			FrameTrends.show();
		}
		private function handleOptionAddFriend(inputText:String):void
		{
			if(inputText !=	null)
			{
				if(inputText.length <= 0)
				{
					FrameInfo.showMessageDialog("","请输入要添加好友的ID或名字!",null,null,true,null);
					return;
				}
				var id:int = int(inputText);
				Client.getInstance().sendPacketLogic(601,[id,inputText]);
			}
			
		}
		private function onFrameMoved(e:Event):void
		{
			//onClick(e);
			FrameClickFriend.hide();
		}
		private function onFrameClose(e:Event):void
		{
			FrameClickFriend.hide();
		}

		public static function phFriends_600(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phFriends_600", msg);
			var nIndex:uint = 0;
			var nType:int = msg[nIndex++];
			var nCount:uint = msg[nIndex++];

			var array:Array = null;
			if(nType == 0) array = CharInfo.m_arFriends;
			if(nType == 1) array = CharInfo.m_arFriendsFavorite;
			if(nType == 2) array = CharInfo.m_arFriendsBoring;
			if(nType == 3) array = CharInfo.m_arFriendsTmp;
			
			array.splice(0,array.length);
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
				obj.value = msg[nIndex++];
				obj.relation = msg[nIndex++];
				obj.love = msg[nIndex++];
				obj.contact_time = msg[nIndex++];
				obj.online = msg[nIndex++];
			}
			if(nType == 3)
				array.sortOn("contact_time",Array.NUMERIC | Array.DESCENDING);
			else
				array.sortOn("m_nLevel",Array.NUMERIC | Array.DESCENDING);
			//CharInfo.m_arFriends.sortOn("online",Array.NUMERIC | Array.DESCENDING);
			var rank:int = 1;
			for each(var objFriend:Object in array)
			{
				objFriend.rank = rank;
				rank++;
			}
			if(isShowing())
				_frame.updateData();
		}
		
		public static function phFriendUpdate_604(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phFriendUpdate_604", msg);
			var nIndex:uint = 0;
			
			//var array:Array = CharInfo.m_arFriends;
			//array.splice(0,array.length);

			var nType:uint = msg[nIndex++];
			
			var array:Array = null;
			if(nType == 0) array = CharInfo.m_arFriends;
			if(nType == 1) array = CharInfo.m_arFriendsFavorite;
			if(nType == 2) array = CharInfo.m_arFriendsBoring;
			if(nType == 3) array = CharInfo.m_arFriendsTmp;
			
			var obj:Object = new Object();
			obj.m_nCharId = msg[nIndex++];
			obj.m_szCharName = msg[nIndex++];
			//obj.figureurl = msg[nIndex++];
			obj.m_nLevel = msg[nIndex++];
			obj.m_nRace = msg[nIndex++];
			obj.m_nGender = msg[nIndex++];
			obj.value = msg[nIndex++];
			obj.relation = msg[nIndex++];
			obj.love = msg[nIndex++];
			obj.contact_time = msg[nIndex++];
			obj.online = msg[nIndex++];
			
			for each(var item:Object in array)
			{
				if(item.m_nCharId == obj.m_nCharId)
				{
					if(obj.online == 1)
					{
						var m_szCharName:String = '';
						if(obj.m_nGender == 0)
							m_szCharName += '<font color="#6fb5eb">';
						if(obj.m_nGender == 1)
							m_szCharName += '<font color="#e81c73">';
						
						m_szCharName += '<a href=\"event:'+obj.m_nCharId+','+obj.m_szCharName+','+obj.m_nLevel+','+obj.m_nRace+','+obj.m_nGender+'\"><u>';
						m_szCharName +=  obj.m_szCharName + '</u></a></font>'
							
						FrameChat.getInstance().addSystemMessage('你的好友'+m_szCharName+'上线了!');
					}
					//FrameChat.getInstance().addSystemMessage('你的好友 '+obj.m_szCharName+(obj.online == 0?' 下线了!':' 上线了!'));
					//item = obj;
					item.m_nCharId = obj.m_nCharId;
					item.m_szCharName = obj.m_szCharName;
					item.figureurl = obj.figureurl;
					item.m_nLevel = obj.m_nLevel;
					item.m_nRace = obj.m_nRace;
					item.m_nGender = obj.m_nGender;
					item.value = obj.value;
					item.relation = obj.relation;
					item.love = obj.love;
					item.contact_time = obj.contact_time;
					item.online = obj.online;
					break;
				}
			}
			if(nType == 3)
				array.sortOn("contact_time",Array.NUMERIC | Array.DESCENDING);
			else
				array.sortOn("m_nLevel",Array.NUMERIC | Array.DESCENDING);
			//array.sortOn("online",Array.NUMERIC | Array.DESCENDING);
			if(isShowing())
				_frame.updateData();
		}
		public static function onFrameClosing(e:Event):void
		{
			if(_frameParent == null)
				return;
			var teamDestX:int = (Engine.W - _frameParent.width)/2;
			var teamDestY:int = (Engine.H - _frameParent.height)/2;
			var tween:TweenLite = TweenLite.to(_frameParent, 0.3, {x:teamDestX, y:teamDestY});
			_frameParent = null;
		}
		public static function onFrameParentClosing(e:Event):void
		{
			if(_frameParent == null)
				return;
			_frameParent.removeEventListener(FrameEvent.FRAME_CLOSING,onFrameParentClosing);
			_frameParent.removeEventListener(AWEvent.HIDDEN,onFrameParentClosing);
			hide();
		}
		
		public static var _frameParent:JFrame = null;
		public static var _frame:FrameFriend = null;
		public static function show(frameParent:JFrame = null):void
		{
			if(isShowing())
			{
				hide();
				return;
			}
			if(_frame == null)
			{
				_frame = new FrameFriend();
				PanelMainHelp.getInstance().addChild(_frame);
				hide();
			}
			_frame.show();
			PanelMainHelp.getInstance().bringToTop(_frame);
			_frame.updateData();
			_frame.invalidate();
			_frame.pack();
			_frame.paintImmediately();
			
			_frameParent = frameParent;
			
			if(_frameParent != null)
			{
				_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
				var leftFrame:JFrame = _frameParent;//_frame;
				var rightFrame:JFrame = _frame;
				
				var leftX:int = (Engine.W - (rightFrame.width+leftFrame.width))/2;
				var leftY:int = (Engine.H - leftFrame.height)/2;
				
				var rightX:int = leftX + leftFrame.width;
				var rightY:int = leftY + (leftFrame.height - rightFrame.height)/2;
				
				var tween:TweenLite = TweenLite.to(leftFrame, 0.3, {x:leftX, y:leftY});
				var list_tween:TweenLite = TweenLite.to(rightFrame, 0.3, {x:rightX, y:rightY});
				
				_frameParent.addEventListener(FrameEvent.FRAME_CLOSING,onFrameParentClosing);
				_frameParent.addEventListener(AWEvent.HIDDEN,onFrameParentClosing);
			}
			else
			{
				if(FrameLover.isShowing())
					FrameLover.hide();
				_frame.setLocationXY(Engine.W - _frame.width-6,(Engine.H - _frame.height)/2+20);
				_frame.show();
				PanelMainHelp.getInstance().bringToTop(_frame);
			}
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
			FrameClickFriend.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
	}
}

import com.*;
import com.Engine.*;
import com.Home.*;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

//import mx.containers.Panel;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.tree.AbstractLayoutCache;

/**
 * MyPaneFriendItem
 */
class PaneFriendItem extends JPanel{
	
	//members define
	private var labelRank:JLabel;
	private var panelImage:JPanel;
	private var labelName:JLabelButton;
	private var labelLevel:JLabel;
	private var panel77:JPanel;
	private var btn_friend_home:JButton;
	private var btn_friend_invade:JButton;
	private var btn_friend_lover:JButton;
	private var btn_friend_match:JButton;
	
	/**
	 * MyPaneFriendItem Constructor
	 */
	public function PaneFriendItem(){
		//component creation
		setSize(new IntDimension(174, 44));
		setPreferredSize(new IntDimension(174, 44));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		labelRank = new JLabel();
		labelRank.setLocation(new IntPoint(1, 0));
		labelRank.setSize(new IntDimension(23, 23));
		labelRank.setPreferredSize(new IntDimension(23, 23));
		labelRank.setText("23");
		
		panelImage = new JPanel();
		panelImage.setLocation(new IntPoint(1, 0));
		panelImage.setSize(new IntDimension(44, 44));
		panelImage.setPreferredSize(new IntDimension(44, 44));
		
		labelName = new JLabelButton();
		labelName.setLocation(new IntPoint(45, 3));
		labelName.setSize(new IntDimension(90, 20));
		labelName.setPreferredSize(new IntDimension(90, 20));
		labelName.setText("label");
		
		labelLevel = new JLabel();
		labelLevel.setLocation(new IntPoint(135, 3));
		labelLevel.setSize(new IntDimension(39, 20));
		labelLevel.setPreferredSize(new IntDimension(39, 20));
		labelLevel.setText("label");
		
		panel77 = new JPanel();
		panel77.setLocation(new IntPoint(94, 27));
		panel77.setSize(new IntDimension(80, 17));
		panel77.setPreferredSize(new IntDimension(80, 17));
		var layout1:FlowWrapLayout = new FlowWrapLayout();
		layout1.setPreferWidth(200);
		layout1.setAlignment(AsWingConstants.CENTER);
		layout1.setHgap(3);
		layout1.setVgap(0);
		layout1.setMargin(false);
		panel77.setLayout(layout1);
		
		btn_friend_home = new JButton();
		btn_friend_home.setLocation(new IntPoint(5, 11));
		btn_friend_home.setSize(new IntDimension(17, 15));
		btn_friend_home.setPreferredSize(new IntDimension(17, 17));
		btn_friend_home.setToolTipText("访问幻境");
		
		btn_friend_invade = new JButton();
		btn_friend_invade.setLocation(new IntPoint(27, 5));
		btn_friend_invade.setSize(new IntDimension(17, 17));
		btn_friend_invade.setPreferredSize(new IntDimension(17, 17));
		btn_friend_invade.setToolTipText("入侵幻境");
		
		btn_friend_lover = new JButton();
		btn_friend_lover.setLocation(new IntPoint(41, 0));
		btn_friend_lover.setSize(new IntDimension(17, 17));
		btn_friend_lover.setPreferredSize(new IntDimension(17, 17));
		btn_friend_lover.setToolTipText("结为情人");
		
		btn_friend_match = new JButton();
		btn_friend_match.setLocation(new IntPoint(24, 23));
		btn_friend_match.setSize(new IntDimension(31, 23));
		btn_friend_match.setPreferredSize(new IntDimension(17, 17));
		btn_friend_match.setToolTipText("元神切磋");
		
		//component layoution
		append(panelImage);
		append(labelName);
		append(labelLevel);
		append(panel77);
		append(labelRank);
		
		panel77.append(btn_friend_home);
		panel77.append(btn_friend_invade);
		panel77.append(btn_friend_lover);
		panel77.append(btn_friend_match);
		
		//-------------------------------------------
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		labelName.setForeground(ASColor.WHITE);
		labelName.setFont(new ASFont("宋体", 13, false, false, true, false));
		labelName.setTextFilters( new Array(filter));
		
		labelName.addActionListener(onBtnName);
		
		labelLevel.setForeground(ASColor.WHITE);
		labelLevel.setFont(font);
		labelLevel.setTextFilters( new Array(filter));
		
		addEventListener(MouseEvent.ROLL_OVER, onRollOver);
		addEventListener(MouseEvent.ROLL_OUT, onRollOut);
		//addEventListener(MouseEvent.CLICK,onClick);
		panelImage.addEventListener(MouseEvent.ROLL_OVER, onRollOverImage);
		panelImage.addEventListener(MouseEvent.ROLL_OUT, onRollOutImage);
		panelImage.addEventListener(MouseEvent.CLICK,onClickImage);

		panelImage.addEventListener(MouseEvent.DOUBLE_CLICK,onDoubleClickImage);
		//buttonMode = true;
		panelImage.buttonMode = true;
		this.setClipMasked(false);
		img_background = new AssetBackground(Client.getUIElement("img_friend_item") as DisplayObject);
		img_background_select = new AssetBackground(Client.getUIElement("img_friend_item_select") as DisplayObject)
		//var img_background:DisplayObject = Client.getUIElement("img_friend_item") as DisplayObject
		setBackgroundDecorator(img_background);
		
		panelImage.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		//panelImage.setEditable(false);
		
		//panelImage.setToolTipText("点击偷窥好友约会!");
		
		btn_friend_home.wrapSimpleButton(Client.getUIElement("btn_friend_home") as SimpleButton);
		btn_friend_home.setText("");
		btn_friend_invade.wrapSimpleButton(Client.getUIElement("btn_friend_invade") as SimpleButton);
		btn_friend_invade.setText("");
		btn_friend_lover.wrapSimpleButton(Client.getUIElement("btn_friend_lover") as SimpleButton);
		btn_friend_lover.setText("");
		btn_friend_match.wrapSimpleButton(Client.getUIElement("btn_friend_match") as SimpleButton);
		btn_friend_match.setText("");
		btn_friend_home.addActionListener(onBtnHome);
		btn_friend_invade.addActionListener(onBtnHomeInvade);
		btn_friend_lover..addActionListener(onBtnLover);
		btn_friend_match..addActionListener(onBtnMatch);
	}
	private function onBtnName(e:Event):void
	{
		if(_item != null)
		{
			//var x : Number = this.x+ panelImage.x + panelImage.width / 2;
			//var y : Number = this.y+ panelImage.y + panelImage.height / 2;
			//FrameClickFriend.show(this.parent as JPanel,x,y,_item);
			if (parent is Container)
			{
				(parent as Container).bringToTop(this);
			}
			var point:IntPoint = AsWingUtils.getStageMousePosition();

			var pointLocal:Point = this.globalToLocal(new Point(point.x,point.y));
			FrameClickFriend.show(this,pointLocal.x,pointLocal.y,_item);
			
		}
	}
	private var img_background:AssetBackground = null;
	private var img_background_select:AssetBackground = null;
	private function onRollOver(event:MouseEvent):void
	{
		if(_item == null)return;
		
		if(getBackgroundDecorator() != img_background_select)
			setBackgroundDecorator(img_background_select);
	}
	
	private function onRollOut(event:MouseEvent):void
	{
		if(_item == null)return;
		if(getBackgroundDecorator() != img_background)
			setBackgroundDecorator(img_background);
	}
	
	private var _filterArray:Array = new Array(new GlowFilter(0xffff00, 1, 20, 20));
	private function onRollOverImage(event:MouseEvent):void
	{
		if(_item == null)return;
		//var filter:GlowFilter;
		//filter = new GlowFilter(0xFFFF00, 1, 2, 2, 100);
		event.target.filters = _filterArray;
		
	}
	
	private function onRollOutImage(event:MouseEvent):void
	{
		if(_item == null)return;
		event.target.filters = null;
	}
	/*private function onClick(event:MouseEvent):void
	{
		//if(event.target == panelImage || panelImage.contains(event.target as DisplayObject) || panelImage.containsChild(event.target as DisplayObject))
		//	return;
		
		//if(event.target is JButton)
		//	return;
		trace('onClick:'+event.target);
		trace('onClick,currentTarget:'+event.currentTarget);
		if(!(event.target is JPanel) && !(event.target is JLabel))
			return;
		//trace('onClick:'+event.target);
		//trace('onClick,currentTarget:'+event.currentTarget);
		if(_item != null)
		{
			var x : Number = this.x+ panelImage.x + panelImage.width / 2;
			var y : Number = this.y+ panelImage.y + panelImage.height / 2;
			FrameClickFriend.show(this.parent as JPanel,x,y,_item);
		}
	}*/
	
	private function onDoubleClickImage(event:MouseEvent):void
	{
		if(_item != null)
		{
			FrameFriendChat.show(_item);
			
			for each(var item:Object in FrameFriendChat.messages)
			{
				if(item.m_nCharId == _item.m_nCharId)
				{
					FrameFriendChat.messages.splice(FrameFriendChat.messages.indexOf(item),1);
					break;
				}
			}
			
		}
	}
	
	private function onClickImage(event:MouseEvent):void
	{
		if(_item != null)
		{
			if (parent is Container)
			{
				(parent as Container).bringToTop(this);
			}
			var point:IntPoint = AsWingUtils.getStageMousePosition();
			
			var pointLocal:Point = this.globalToLocal(new Point(point.x,point.y));
			FrameClickFriend.show(this,pointLocal.x,pointLocal.y,_item);
			
		}
	}
	private function onBtnHome(e:Event):void
	{
		Home.visitHome(int(_item.m_nCharId));
	}
	private function onBtnHomeInvade(e:Event):void
	{
		Home.visitHome(int(_item.m_nCharId),true);
	}
	private function onBtnLover(e:Event):void
	{
		//FrameInfo.showInputDialog("",_item.m_szCharName+' 身价:'+_item.value + ",请输入新身价:",handleOptionLover,"",null,true,null);
		FrameLover.showTokenOfLove(_item);
	}
	
	/*private function handleOptionLover(inputText:String):void
	{
		if(inputText !=	null)
		{
			if(inputText.length <= 0 || int(inputText) == 0)
			{
				FrameInfo.showMessageDialog("","请输入出价!",null,null,true,null);
				return;
			}
			Client.getInstance().sendPacketLogic(1200,[_item.m_nCharId,int(inputText)]);
		}
		
	}*/
	private function onBtnMatch(e:Event):void
	{
		Client.getInstance().sendPacketLogic(300,[int(SceneBattle.BATTLE_TYPE_PVP_COMPARE),_item.m_nCharId]);
	}
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		//panelImage.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_default_image") as DisplayObject));
		_item = val;
		//panelImage.setBackgroundDecorator(null);
		labelRank.setText("");
		labelName.setText("");
		labelLevel.setText("");
		
		btn_friend_home.setVisible(false);
		btn_friend_invade.setVisible(false);
		btn_friend_lover.setVisible(false);
		btn_friend_match.setVisible(false);
		setBackgroundDecorator(null);
		panelImage.setBackgroundDecorator(null);
		if(_item == null)
		{
			return;
		}
		setBackgroundDecorator(img_background);
		btn_friend_home.setVisible(true);
		btn_friend_invade.setVisible(true);
		btn_friend_lover.setVisible(true);
		btn_friend_match.setVisible(true);
		
		//panelImage.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_map_"+ _item.csv_id) as DisplayObject));
		labelRank.setText(_item.rank);
		labelName.setText(_item.m_szCharName);
		labelLevel.setText('Lv.'+_item.m_nLevel);
		if(_item.online == 1)
			labelName.setForeground(new ASColor(_item.m_nGender == 0 ? Engine.colorBoy:Engine.colorGirl));
		else
			labelName.setForeground(ASColor.GRAY);
		
		if(_item.figureurl != null && _item.figureurl.length != 0)
		{
			var lc:LoaderContext = new LoaderContext(true);
			_loader = new Loader();
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImageLoaded);
			_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadedError);
			_loader.load(new URLRequest(_item.figureurl),lc);
			panelImage.setBackgroundDecorator(null);
			
		}
		else
		{
			panelImage.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		}
		panelImage.pack();
		panelImage.paintImmediately();
		pack();
		this.paintImmediately();
		
	}
	
	public function clear():void
	{
		if(_bmData != null)
		{
			_bmData.dispose();
			_bmData = null;
		}
		if(_loader != null)
		{
			_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onImageLoaded);
			_loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onImageLoadedError);
			_loader.unloadAndStop(false);
			_loader = null;
		}
		setBackgroundDecorator(null);
		panelImage.setBackgroundDecorator(null);
	}
	private var _loader:Loader = null; 
	private function onImageLoaded(e:Event):void
	{
		
		var loadinfo:LoaderInfo = e.target as LoaderInfo;
		
		loadinfo.removeEventListener(Event.COMPLETE,onImageLoaded);
		loadinfo.removeEventListener(IOErrorEvent.IO_ERROR,onImageLoadedError);
		if(_loader != null)
		{
			panelImage.setBackgroundDecorator(null);   
			var loader2:Loader = new Loader();  
			loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, loader2Complete);  
			loader2.loadBytes(loadinfo.bytes);
		}
	}  
	private var _bmData:BitmapData = null;
	private function loader2Complete(event:Event):void  
	{  
		if(_bmData != null)
		{
			_bmData.dispose();
			_bmData = null;
		}
		var loadinfo:LoaderInfo = event.target as LoaderInfo;
		loadinfo.removeEventListener(Event.COMPLETE,loader2Complete);
		_bmData = new BitmapData(loadinfo.content.width,loadinfo.content.height,true,0x00000000);
		_bmData.draw(loadinfo.content);
		var _bm:Bitmap = new Bitmap(_bmData);
		_bm.scaleX = panelImage.width / _bm.width;
		_bm.scaleY = panelImage.height / _bm.height;
		panelImage.setBackgroundDecorator(new AssetBackground(_bm as DisplayObject));
		loadinfo.loader.unload();
		loadinfo = null;
		if(_loader!= null)
		{
			_loader.unloadAndStop(false);
			_loader = null;
		}
	}
	
	private function onImageLoadedError(e:IOErrorEvent):void
	{
		trace("onImageLoadedError"+e.text);
	}
	public function get item():Object
	{
		return _item;
	}
	
	//_________getters_________
	
}

class FrameClickFriend extends JFrame
{
	//members define
	private var btnChat:JLabelButton;
	private var btnLover:JLabelButton;
	private var btnStall:JLabelButton;
	private var btnWatchFriend:JLabelButton;
	private var btnAddFriend:JLabelButton;
	private var btnCompare:JLabelButton;
	private var btnRemoveFriend:JLabelButton;
	private var btnClose:JLabelButton;
	
	public function FrameClickFriend()
	{
		setResizable(false); 
		setClosable(false);
		setDragable(false);
		setTitleBar(null);
		setBackgroundDecorator(null);
		setBorder(new EmptyBorder());
		
		//component creation
		setSize(new IntDimension(60, 138));
		setPreferredSize(new IntDimension(60, 138));
		var border0:LineBorder = new LineBorder();
		border0.setInterior(null);
		border0.setColor(new ASColor(0x0, 1));
		border0.setThickness(1);
		border0.setRound(0);
		setBorder(border0);
		var layout1:BoxLayout = new BoxLayout();
		layout1.setAxis(AsWingConstants.VERTICAL);
		layout1.setGap(0);
		getContentPane().setLayout(layout1);
		
		btnChat = new JLabelButton();
		btnChat.setLocation(new IntPoint(0, 0));
		btnChat.setSize(new IntDimension(58, 17));
		btnChat.setText("聊天");
		
		btnLover = new JLabelButton();
		btnLover.setLocation(new IntPoint(0, 20));
		btnLover.setSize(new IntDimension(58, 17));
		btnLover.setText("定情");
		
		btnStall = new JLabelButton();
		btnStall.setLocation(new IntPoint(0, 20));
		btnStall.setSize(new IntDimension(58, 17));
		btnStall.setText("摊位");
		
		btnWatchFriend = new JLabelButton();
		btnWatchFriend.setLocation(new IntPoint(0, 0));
		btnWatchFriend.setSize(new IntDimension(58, 17));
		btnWatchFriend.setText("查看");
		
		btnAddFriend = new JLabelButton();
		btnAddFriend.setLocation(new IntPoint(5, 5));
		btnAddFriend.setSize(new IntDimension(58, 17));
		btnAddFriend.setText("加为好友");
		
		btnCompare = new JLabelButton();
		btnCompare.setLocation(new IntPoint(1, 96));
		btnCompare.setSize(new IntDimension(58, 17));
		btnCompare.setText("切磋");
		
		btnRemoveFriend = new JLabelButton();
		btnRemoveFriend.setLocation(new IntPoint(62, 5));
		btnRemoveFriend.setSize(new IntDimension(58, 17));
		btnRemoveFriend.setText("删除");
		
		btnClose = new JLabelButton();
		btnClose.setLocation(new IntPoint(0, 38));
		btnClose.setSize(new IntDimension(58, 17));
		btnClose.setText("关闭");
		
		
		//component layoution
		getContentPane().append(btnChat);
		getContentPane().append(btnLover);
		getContentPane().append(btnStall);
		getContentPane().append(btnWatchFriend);
		if(_obj.relation == 0)
			getContentPane().append(btnAddFriend);
		getContentPane().append(btnCompare);
		getContentPane().append(btnRemoveFriend);
		getContentPane().append(btnClose);
		
		//--------------------
		//setBackgroundDecorator(new SolidBackground(new ASColor(ASColor.DARK_GRAY.getARGB(),1.0)));
		btnClose.addActionListener(onBtnClose);
		btnWatchFriend.addActionListener(onBtnWatchFriend);
		btnStall.addActionListener(onBtnStall);
		btnLover.addActionListener(onBtnLover);
		btnAddFriend.addActionListener(onBtnAddFriend);
		btnCompare.addActionListener(onBtnAttackFriend);
		btnRemoveFriend.addActionListener(onBtnRemoveFriend);
		btnChat.addActionListener(onBtnChat);
		//btnWatchFriend.setEnabled(false);

		btnLover.setForeground(ASColor.WHITE);
		btnLover.setRollOverColor(ASColor.YELLOW);
		btnLover.setPressedColor(ASColor.BLUE);
		
		btnStall.setForeground(ASColor.WHITE);
		btnStall.setRollOverColor(ASColor.YELLOW);
		btnStall.setPressedColor(ASColor.BLUE);
		
		btnChat.setForeground(ASColor.WHITE);
		btnChat.setRollOverColor(ASColor.YELLOW);
		btnChat.setPressedColor(ASColor.BLUE);
		
		btnWatchFriend.setForeground(ASColor.WHITE);
		btnWatchFriend.setRollOverColor(ASColor.YELLOW);
		btnWatchFriend.setPressedColor(ASColor.BLUE);
		
		btnAddFriend.setForeground(ASColor.WHITE);
		btnAddFriend.setRollOverColor(ASColor.YELLOW);
		btnAddFriend.setPressedColor(ASColor.BLUE);
		
		btnCompare.setForeground(ASColor.WHITE);
		btnCompare.setRollOverColor(ASColor.YELLOW);
		btnCompare.setPressedColor(ASColor.BLUE);
		
		btnRemoveFriend.setForeground(ASColor.WHITE);
		btnRemoveFriend.setRollOverColor(ASColor.YELLOW);
		btnRemoveFriend.setPressedColor(ASColor.BLUE);
		
		btnClose.setForeground(ASColor.WHITE);
		btnClose.setRollOverColor(ASColor.YELLOW);
		btnClose.setPressedColor(ASColor.BLUE);
		
		setBackgroundDecorator(new SolidBackground(new ASColor(0x0e3c3b,1.0)));
	}
	public function onBtnChat(e:Event):void
	{
		FrameFriendChat.show(_obj);
		
		for each(var item:Object in FrameFriendChat.messages)
		{
			if(item.m_nCharId == _obj.m_nCharId)
			{
				FrameFriendChat.messages.splice(FrameFriendChat.messages.indexOf(item),1);
				break;
			}
		}
		
		hide();
	}
	
	public function onBtnLover(e:Event):void
	{
		//Client.getInstance().sendPacketLogic(1200,[_obj.m_nCharId]);
		hide();
		//FrameInfo.showInputDialog("",_obj.m_szCharName+' 身价:'+_obj.value + ",请输入新身价:",handleOptionLover,"",null,true,null);
		FrameLover.showTokenOfLove(_obj);
	}
	
	/*private function handleOptionLover(inputText:String):void
	{
		if(inputText !=	null)
		{
			if(inputText.length <= 0 || int(inputText) == 0)
			{
				FrameInfo.showMessageDialog("","请输入出价!",null,null,true,null);
				return;
			}
			Client.getInstance().sendPacketLogic(1200,[_obj.m_nCharId,int(inputText)]);
		}
		
	}*/
	
	public function onBtnStall(e:Event):void
	{
		Client.getInstance().sendPacketLogic(2100,[_obj.m_nCharId]);
		FrameStall.nWatchCharId = _obj.m_nCharId;
		hide();
	}
	public function onBtnClose(e:Event):void
	{
		hide();
	}
	public function onBtnWatchFriend(e:Event):void
	{
		Client.getInstance().sendPacketLogic(605,[int(_obj.m_nCharId)]);
		hide();
	}
	public function onBtnAddFriend(e:Event):void
	{
		Client.getInstance().sendPacketLogic(601,[_obj.m_nCharId]);
		hide();
	}
	public function onBtnAttackFriend(e:Event):void
	{
		Client.getInstance().sendPacketLogic(300,[int(SceneBattle.BATTLE_TYPE_PVP_COMPARE),_obj.m_nCharId]);
		hide();
	}
	
	public function onBtnRemoveFriend(e:Event):void
	{
		hide();
		var pane:FrameInfo = FrameInfo.showMessageDialog("","是否删除好友 "+_obj.m_szCharName+" ?",handleOptionRemoveFriend,null,true,null,JOptionPane.YES|JOptionPane.NO);
	}


	private static function handleOptionRemoveFriend(button:uint):void
	{
		if(button == JOptionPane.YES)
		{
			Client.getInstance().sendPacketLogic(602,[_obj.m_nCharId]);
		}
	}

	private static var _obj:Object = null;
	private static var _frame:FrameClickFriend = null;
	public static function show(parent:JPanel,x:uint,y:uint,obj:Object):void
	{
		_obj = obj;
		if(_frame == null)
		{
			_frame = new FrameClickFriend();
		}
		parent.addChild(_frame);
		_frame.show();
		_frame.pack();
		//if(x+_frame.width > Engine.W)
		//	x = Engine.W - _frame.width;
		_frame.setLocationXY(x,y - _frame.height);
		
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
	}
	public static function isShowing():Boolean
	{
		if(_frame != null&& _frame.isShowing())
		{
			return true;
		}
		return false;
	}
}